import request from '@/utils/request.js'

// 查询圈子列表
export function listTopic(query) {
  return request.get('/app/topic/list', query)
}

// 查询我加入的圈子
export function listMyTopics(query) {
  return request.get('/app/topic/my', query)
}

// 查询热门圈子
export function listHotTopics(query) {
  return request.get('/app/topic/hot', query)
}

// 查询推荐圈子
export function listRecommendTopics(query) {
  return request.get('/app/topic/recommend', query)
}

// 查询圈子详情
export function getTopicDetail(topicId) {
  return request.get(`/app/topic/${topicId}`)
}

// 创建圈子
export function createTopic(data) {
  return request.post('/app/topic', data)
}

// 更新圈子
export function updateTopic(data) {
  return request.put('/app/topic', data)
}

// 加入圈子
export function joinTopic(topicId) {
  return request.post(`/app/topic/${topicId}/join`)
}

// 退出圈子
export function quitTopic(topicId) {
  return request.post(`/app/topic/${topicId}/quit`)
}

// 查询圈子成员
export function listTopicMembers(topicId, query) {
  return request.get(`/app/topic/${topicId}/members`, query)
}

// 设置成员角色
export function setMemberRole(topicId, userId, role) {
  return request.put(`/app/topic/${topicId}/members/${userId}/role`, { role })
}

// 禁言/解除禁言成员
export function toggleMemberMute(topicId, userId, isMuted) {
  return request.put(`/app/topic/${topicId}/members/${userId}/mute`, { isMuted })
}

// 移除成员
export function removeMember(topicId, userId) {
  return request.delete(`/app/topic/${topicId}/members/${userId}`)
}